package cn.rkylin.oms.order.adapter;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.common.base.AbstractAdapterFactory;
import cn.rkylin.oms.order.domain.Order;
import cn.rkylin.oms.order.domain.OrderStatusEnum;
import cn.rkylin.oms.system.shop.domain.Shop;
import cn.rkylin.oms.system.shop.vo.ShopVO;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * 订单适配器
 * 
 * @author wangxiaoyi
 * @version 1.0
 * @created 13-1月-2017 09:11:14
 */
public abstract class OrderAdapter {
	/**
	 * 数据库访问对象
	 */
	@Autowired
	private IDataBaseFactory dao;

	// @Autowired
	private OrderVisitor orderVisitor;

	public void finalize() throws Throwable {

	}

	/**
	 * 构造函数
	 */
	public OrderAdapter() {

	}

	/**
	 * 下载平台订单
	 * 
	 * @return ArrayList<Order> 返回订单列表
	 * 
	 * @param shopId
	 *            店铺id
	 * @param dateTimeStart
	 *            开始时间
	 * @param dateTimeEnd
	 *            结束时间
	 * @throws Exception
	 */
	public abstract int download(String shopId, String dateTimeStart, String dateTimeEnd) throws Exception;

	/**
	 * 下载平台订单
	 * 
	 * @param map
	 *            rds的检索条件
	 * @return
	 * @throws Exception
	 */
	public abstract int download(Map<String, String> map) throws Exception;

	public OrderVisitor getOrderVisitor() {
		return orderVisitor;
	}

	public void setOrderVisitor(OrderVisitor orderVisitor) {
		this.orderVisitor = orderVisitor;
	}

	/**
	 * 获取店铺
	 * 
	 * @param shopId
	 * @return
	 */
	protected ShopVO getShop(String shopId) {
		return AbstractAdapterFactory.getShop(shopId);
	}

	/**
	 * 平台发货
	 * 
	 * @param shopId
	 *            店铺id
	 * @param dateTimeStart
	 *            开始时间
	 * @param dateTimeEnd
	 *            结束时间 return 结果数量
	 * @throws Exception
	 *             异常
	 */
	public abstract Map<String, Object> consign(String shopId, String dateTimeStart, String dateTimeEnd)
			throws Exception;

}
